while True:
    pm = input("请输入pm2.5的值:")
    if pm.isdigit():
        if int(pm) <= 50:
            print("空气质量为优")
        elif 51 <= int(pm) <= 100:
            print("空气质量为良")
        elif 101 <= int(pm) <= 150:
            print("空气质量为轻度污染")
        elif 151 <= int(pm) <= 200:
            print("空气质量为中度污染")
        elif 201 <= int(pm) <= 300:
            print("空气质量为重度污染")
        elif int(pm) > 300:
            print("空气质量为严重污染")
    elif str(pm) == 'Q':
        print("已退出")
        break
    else:
        print("请重新输入")
